import React, { Component } from 'react';
import Son from '../PropsTest2';


export default class Father extends Component {
    constructor(props) {
        super(props);
      this.state = {
          seconds: 0,
          statusValue: false
        }
  }
  
  getValue = () => {
    this.setState({statusValue: true})
  }

  // 计数方法
  tick() {
    this.setState(() => ({
      seconds: this.state.seconds + 1
    }));
  };

  // 挂载
  componentDidMount() {
    this.interval = setInterval(() =>
      this.tick(), 1000);
  }

  // 卸载
  componentWillUnmount() {
    clearInterval(this.interval);
  }

  render() {
    return (
      <div>
        Seconds: {this.state.seconds}
        <Son seconds={this.state.seconds}></Son>
      </div>
    )
  }
}
